import {
  showText
} from "../../utils/util"
Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  /**
   * 组件的属性列表
   */
  properties: {
    tabIndex: {
      type: Number,
      value: 0,
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    bottomInset: 20,
    imgUri: getApp().globalData.imgUri,
  },
  attached() {
    const systemInfo = wx.getWindowInfo();
    const bottomInset = Math.abs(systemInfo.safeArea.bottom - systemInfo.windowHeight);
    console.log('Bottom inset: ', bottomInset);
    this.setData({
      bottomInset:bottomInset || 20
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    _showChange(show) {
      const animated = this.data.animated
      let displayStyle = ''
      if (animated) {
        displayStyle = `opacity: ${show ? '1' : '0'};transition: opacity 0.5s;`
      } else {
        displayStyle = `display: ${show ? '' : 'none'}`
      }
      this.setData({
        displayStyle
      })
    },
    back() {
      const data = this.data
      if (data.delta) {
        wx.navigateBack({
          delta: data.delta
        })
      }
      this.triggerEvent('back', {
        delta: data.delta
      }, {})
    },
    goToOther(){
      wx.navigateToMiniProgram({
        appId: "wx1fe9cc1ada6e49b8",
        path: "/pages/index/index"
      });
    },
    goToUrl(e){
      let { url } = e.currentTarget.dataset
      if(url){
        wx.setStorageSync('module_url', url);
        var phone = wx.getStorageSync('phone');
        if(phone){
          wx.navigateTo({
            url:url
          })
        }else{
          wx.navigateTo({
            url:'/pages/register/register'
          })
        }
      }else{
        showText('您好，该活动暂未开始，敬请期待！')
      }
    },
    cli_my(){
      wx.navigateTo({
        url: '/pages/myGemo/myGemo'
      })
    },
    cli_club(){
      wx.navigateTo({
        url: '/pages/club/club'
      })
    },
    cli_space(){
      wx.navigateTo({
        url: '/pages/space/space'
      })
    },
    cli_shop(){
      wx.navigateTo({
        url: '/shop/index/index'
      })
    },
  }
})